< previous page page_372 next page >

Page 372
Step 2:
Eliminate Unnecessary Information
A header file may include information that is used only when building the DLL as well as information needed by those using the DLL. This is the case with both the cpuid.h and speed.h header files. Deleting the private information is a good first step, as it will save you the effort of converting code that will never be used. The cpuid.bas file only comments out unnecessary code rather than deleting it outright in order to illustrate the process more clearly. How do you spot unnecessary code?
Look for Private Functions
One way to spot a private function is to look at the comments within the header file itself. The cpuid.h file makes it easy. Halfway through the file is the following line:
// Private Function Declarations ///////////////////////////////'
This line suggests that everything that follows is private, which turns out to be the case. Everything after this line is commented out and can be deleted.
You can also use the dumpinfo.exe utility (on the CD provided with this book) to see what functions the DLL actually exports. Any function that does not appear in the export list is private by definition.
Check for Code Excluded Via Conditional Compilation
Visual Basic supports conditional compilation using the #if, #else, and #endif constructs. C and C++ support these and a few other conditional compilation terms. At the start of many C/C++ header files, you'll see code such as this near the top of the file:
#ifndef cpuid_h
#define cpuid_h
followed by the following line near the end of the file:
#endif cpuid_h
The #ifndef directive means "compile the following lines if the following variable is not defined." The #ifdef directive is similar, except that it compiles the code only if the variable is defined. You see, unlike Visual Basic, it is possible for a C

 
< previous page page_372 next page >